﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace DataLayer
{
    public class dlonetask
    {

        public DataSet getonetask(int taskid)
        {
            string connStr = ConfigurationManager.ConnectionStrings["constring"].ConnectionString;
            string querystring = @"SELECT Tasks.*, Product.Name as ProductName, Users.Name AS UserName, Users.FirstName, UserStory.Titel AS UserStoryTitel, Sprints.Titel AS SprintTitel, Impediments.Titel AS ImpedimentTitel, 
                  Impediments.Description AS ImpedimentDescription
FROM     Teams INNER JOIN
                  Sprints ON Teams.TeamID = Sprints.TeamId INNER JOIN
                  UserStory ON Sprints.SprintId = UserStory.SprintID INNER JOIN
                  Product ON Sprints.ProductID = Product.ProductId INNER JOIN
                  Tasks ON UserStory.UserStoryId = Tasks.UserStoryId INNER JOIN
                  Impediments ON Tasks.TaskId = Impediments.TaskId INNER JOIN
                  Users ON Tasks.UserId = Users.UserID
Where Tasks.TaskId = '"+taskid +"'";

            SqlConnection connection = new SqlConnection(connStr);
            SqlCommand querylogin = new SqlCommand(querystring, connection);

            SqlDataAdapter myadapter = new SqlDataAdapter(querylogin);
            DataSet mydataset = new DataSet();

            myadapter.Fill(mydataset);

            return mydataset;

        }

    }
}
